#!/bin/bash
if [ $# -lt 3 ] 
then
    echo "Usage: ./statWords.sh srcFile dstFile";
    exit 1;
else
    t_srcFile=$1
    c_srcFile=$2
    dstFile=$3
fi

echo "统计每个问题分词后的结果"
awk '
BEGIN {
    FS="\t";
}
FILENAME==ARGV[1]{
    for (id in titleArray) {
        if(cnt[titleArray[id]]) {
            cnt[titleArray[id]] +=3;
        } else {
            cnt[titleArray[id]] =3;
        }
    }
}
FILENAME==ARGV[2]{
    print "2"$0;
}
{
    split($2, titleArray, " ");
    split($3, contentArray, " ");
    
    for (id in contentArray) {
        if(cnt[contentArray[id]]) {
            cnt[contentArray[id]] +=1;
        } else {
            cnt[contentArray[id]] =1;
        }
    }
    printf("%d ", $1);
    for (term in cnt) {
        printf("%s@%d,", term, cnt[term]);
        delete cnt[term];
    }
    printf("\n");
}' $srcFile".split"
